package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GenePCRDAO;
import lab.gene.dao.GeneDAO;
import lab.user.dao.UserDAO;
import lab.gene.pojo.Gene;
import lab.user.pojo.User;
import lab.gene.pojo.GenePCR;
import lab.gene.service.GenePCRService;


public class GenePCRServiceImpl implements GenePCRService {

	@Override
	public void addGenePCR(String geneName, String userName, String amplicon, Integer size, String pcrType, String comment, Date recordDate, String stepType) {
		// TODO Auto-generated method stub
		GenePCRDAO dao = new GenePCRDAO();
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		GenePCR pcr = new GenePCR();
		pcr.setAmplicon(amplicon);
		pcr.setComment(comment);
		pcr.setDateModified(new Date());
		pcr.setGene(g);
		pcr.setPcrType(pcrType);
		pcr.setRecordDate(recordDate);
		pcr.setSize(size);
		pcr.setUser(u);
		pcr.setStepType(stepType);
		dao.addGenePCR(pcr);

	}

	@Override
	public GenePCR getGenePCRByGeneName(String geneName, String pcrType, String stepType) {
		// TODO Auto-generated method stub
		GenePCR genePCR = null;
		GenePCRDAO dao = new GenePCRDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		genePCR = dao.getGenePCR(gene, pcrType, stepType);
		return genePCR;
	}

	@Override
	public List<GenePCR> getGenePCRHistory(String geneName, String pcrType, String stepType) {
		
		List<GenePCR> g = null;
		GenePCRDAO dao = new GenePCRDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		g = dao.getGenePCRHistory(gene, pcrType, stepType);
		return g;
		
	}

}
